﻿using ServiceStack.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SmartSSO.Cache
{
   /// <summary>
   /// Redis缓存组件
   /// </summary>
    public sealed class RedisCacheContext:CacheContext
    {
        private readonly RedisClient redisClient = new RedisClient("127.0.0.1", 6379, "123456");
        public override void Init()
        {
        }

        public override T Get<T>(string key)
        {
            return redisClient.Get<T>(key);
        }

        public override bool Set<T>(string key, T t)
        {
            return redisClient.Set( key, t);
        }

        public override bool Remove(string key)
        {
            return redisClient.Remove(key);
        }

        public override void Dispose()
        {
            if (redisClient != null)
            {
                redisClient.Dispose();
            }
        }
    }
}